var vm = new Vue({
	el: '#app',
	data: {
		items: [],
		loaded: false
	},
	mounted: function() {
		data();
		getrecordOfReceipts();
		adminSumInWallet();
		adminSumInWallet2();
	}
});
var SearchFromDate, SearchToDate;
var data, obj;

function getrecordOfReceipts() {
	var getrecordOfReceipts = {
		rows: 10,
		page: 1,
		coinId: 9,
		id: obj.result.id,
		userName: obj.result.userName,
		addr: '',
		status: '',
		startTime: SearchFromDate,
		endTime: SearchToDate
	}
	$.ajax({
		type: "POST",
		url: ip + "platform/user/userInWalletList.m",
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		data: getrecordOfReceipts,
		success: function(data) {
			if(data.statusCode == 0) {
				if(data.result.result == '') {
					$("#row").html('<div align="center">暂无记录</div>');
				}
				vm.loaded = true;
				$("#SearchFromDate").text(SearchFromDate);
				$("#SearchToDate").text(SearchToDate);
				var html = '';
				for(var i = 0; i < (data.result.result).length; i++) {
					html += '<ul class="accordion">' +
						'<li>' +
						'<div class="accordion-tit">' +
						'<div class="weui-cell">' +
						'<div class="weui-cell__bd">' +
						data.result.result[i].createTime +
						'</div>' +
						'<div class="weui-cell__ft">' +
						data.result.result[i].num +
						'</div>' +
						'</div>' +
						'</div>' +
						'<div class="weui-cells f15">' +
						'<div class="weui-cell" style="display:block;">' +
						'<div class="weui-cell__bd">' +
						'<p>转款人钱包地址</p>' +
						'</div>' +
						'<div class="weui-cell__ft">' +
						data.result.result[i].addr +
						'</div>' +
						'</div>' +
						'<div class="weui-cell">' +
						'<div class="weui-cell__bd">' +
						'<p>币种</p>' +
						'</div>' +
						'<div class="weui-cell__ft">' +
						'(' +
						data.result.result[i].coinTitle +
						')' +
						data.result.result[i].coinName +
						'</div>' +
						'</div>' +
						'<div class="weui-cell">' +
						'<div class="weui-cell__bd">' +
						'<p>转账金额</p>' +
						'</div>' +
						'<div class="weui-cell__ft">' +
						data.result.result[i].num +
						'</div>' +
						'</div>' +
						'<div class="weui-cell">' +
						'<div class="weui-cell__bd">' +
						'<p>备注</p>' +
						'</div>' +
						'<div class="weui-cell__ft">' +
						data.result.result[i].remark +
						'</div>' +
						'</div>' +
						'<div class="weui-cell">' +
						'<div class="weui-cell__bd">' +
						'<p>转账时间</p>' +
						'</div>' +
						'<div class="weui-cell__ft">' +
						'</div>' +
						data.result.result[i].updateTime +
						'</div>' +
						'</div>' +
						'</li>' +
						'</ul>';
				}
				$("#row").append(html);
				//列表伸缩
				$('.accordion-tit').click(function() {
					$parent = $(this).parent('li');
					if($parent.hasClass('cur')) {
						$parent.removeClass('cur');
						$parent.siblings().removeClass('cur');
					} else {
						$parent.addClass('cur');
						$parent.siblings().removeClass('cur');
					}
				});
			} else {
				$.toptip(data.resultDesc, 'error');
			}
		}
	});
}
/**
 * 转张记录的累计转张
 */

function data() {
	var myDate = new Date();
	var nowDate = myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + myDate.getDate();
	SearchFromDate = '1970-01-01';
	SearchToDate = nowDate;
	$("#SearchFromDate").text(SearchFromDate);
	$("#SearchToDate").text(SearchToDate);
	data = localStorage.getItem("data");
	obj = JSON.parse(data);
}

function adminSumInWallet() {
	var adminSumOutWalletReqbody = {
		coinId: 9,
		id: obj.result.id,
		userName: obj.result.userName,
		addr: '',
		status: '',
		startTime: SearchFromDate,
		endTime: SearchToDate
	}
	$.ajax({
		type: "POST",
		url: ip + "platform/user/serverSumInWallet.m",
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		data: adminSumOutWalletReqbody,
		success: function(data) {
			if(data.statusCode == 0) {
				$("#SearchFromDate").text(SearchFromDate);
				$("#SearchToDate").text(SearchToDate);
				$("#bd").text(data.result);
				// 成功之后关掉弹窗
				$(document).on("click", ".weui-btn_plain-confirm", function() {
					$.closePopup("#half");
				});
			} else {
				$.toptip(data.resultDesc, 'error');
			}
		}
	});
}

function adminSumInWallet2() {
	var adminSumOutWalletReqbody2 = {
		coinId: 9,
		id: obj.result.id,
		userName: obj.result.userName,
		addr: '',
		status: '',
		startTime: '',
		endTime: ''
	}
	$.ajax({
		type: "POST",
		url: ip + "platform/user/serverSumInWallet.m",
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		data: adminSumOutWalletReqbody2,
		success: function(data) {
			if(data.statusCode == 0) {
				$("#bbd").text(data.result);
			} else {
				$.toptip(data.resultDesc, 'error');
			}
		}
	});
}